# -*- encoding: utf-8 -*-
"""
@author: CarpeDiem
@data: 22/9/18
@version: 0.1
@description: 穷举法算出回文数
@method: +1遍历，显然短时间内没法计算，要求是合法日期的八位数，感觉自己这个写法很笨，变成数字列表，然后翻转
两种格式：ABABBABA
"""
import datetime
input_date = input()
count_date = datetime.datetime.strptime(input_date, "%Y%m%d")
flag = True
while True:
    count_date = count_date + datetime.timedelta(1)
    new_date = count_date.strftime("%Y%m%d")
    if new_date == new_date[::-1]:
        if flag:
            print(new_date)
            flag = False
        if new_date[0] == new_date[2] == new_date[5] == new_date[7] and new_date[1] == new_date[3] == new_date[4] == new_date[6]:
            print(new_date)
            break